package com.tornainbow;

import java.io.Serializable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 *
 * @author mcrysler
 */
public class Field implements Serializable {
    // Define a logger for this class
    private static final Logger logger = LoggerFactory.getLogger(Field.class);
    
    // Define private class variables
    private volatile String name = "";
    private volatile String canonicalizedName = "";
    private volatile String classification = "";
    private volatile String accessControls = "";
    private volatile String value = "";
    
    /**
     * The required no-argument constructor used for serialization
     */
    public Field() {
        super();
    }
    
    /**
     * Sets the private class variables
     * @param name The name to associate to this object
     * @param value The value to associate to this object
     */
    public Field(String name, String value) {
        this.name = name;
        this.value = value;
    }
    
    /**
     * Sets the name to associate to this object
     * @param name The name to associate to this object
     */
    public void setName(String name) {
        this.name = name;
        logger.debug("Set name to: {}", this.name);
    }
    
    /**
     * Returns the name associated to this object
     * @return The name associated to this object
     */
    public String getName() {
        return this.name;
    }
    
    /**
     * Sets the canonicalized name to associate to this object
     * @param canonicalizedName The canonicalized name to associate to this object
     */
    public void setCanonicalizedName(String canonicalizedName) {
        this.canonicalizedName = canonicalizedName;
        logger.debug("Set canonicalized name to: {}", canonicalizedName);
    }
    
    /**
     * Returns the canonicalized name associated to this object
     * @return The canonicalized name associated to this object
     */
    public String getCanonicalizedName() {
        return this.canonicalizedName;
    }
    
    /**
     * Sets the classification to associate to this object
     * @param classification The classification to associate to this object
     */
    public void setClassification(String classification) {
        this.classification = classification;
        logger.debug("Set classification to: {}", this.classification);
    }
    
    /**
     * Returns the classification associated to this object
     * @return The classification associated to this object
     */
    public String getClassification() {
        return this.classification;
    }
    
    /**
     * Sets the access controls to associate to this object
     * @param accessControls The access controls to associate to this object
     */
    public void setAccessControls(String accessControls) {
        this.accessControls = accessControls;
        logger.debug("Set access controls to: {}", this.accessControls);
    }
    
    /**
     * Returns the access controls associated to this object
     * @return The access controls associated to this object
     */
    public String getAccessControls() {
        return this.accessControls;
    }
    
    /**
     * Sets the value to associate to this object
     * @param value The value to associate to this object
     */
    public void setValue(String value) {
        this.value = value;
        logger.debug("Set value to: {}", value);
    }
    
    /**
     * Returns the value associated to this object
     * @return The value associated to this object
     */
    public String getValue() {
        return this.value;
    }
    
    @Override
    public String toString() {
        StringBuilder builder = new StringBuilder();
        builder.append("\tField Name: ").append(this.getName()).append("\n");
        builder.append("\tCanonicalized Name: ").append(this.getName()).append("\n");
        builder.append("\tField Classification: ").append(this.getClassification()).append("\n");
        builder.append("\tField Access Controls: ").append(this.getAccessControls()).append("\n");
        builder.append("\tField Value: ").append(this.getValue()).append("\n");
        return builder.toString();
    }
}
